<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>商城后台</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" th:href="@{/lib/layui-v2.5.5/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{/css/public.css}" media="all">
    <link rel="stylesheet" th:href="@{/lib/layui_ext/dtree/dtree.css}" >
    <link rel="stylesheet" th:href="@{/lib/layui_ext/dtree/font/dtreefont.css}" >
    <style>
        body {
            background-color: #ffffff;
        }
        .layui-table-cell {
            height: auto !important;
            white-space: normal;
        }
    </style>


</head>
<body>

<span th:replace="common_page::common"></span>

<div class="layuimini-container" style="height:100%">

    <div class="layuimini-main" >
        <div class="layui-tab layui-tab-brief">
            <ul class="layui-tab-title">
                <li class="layui-this">订单信息</li>
            </ul>

            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <div class="layui-form layuimini-form">
                        <input type="hidden" name="id" id="id" th:value="${model.id}">
                        <div class="layui-inline" style="width:80%">
                            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                                <legend>订单详情</legend>
                            </fieldset>

                                <div class="layui-form-item" >
                                    <div class="layui-inline" style="width:40%">
                                        <label class="layui-form-label " >主订单号</label>
                                        <div class="layui-input-block">
                                            <input type="text"  th:value="${model.mainOrderNo}" disabled="disabled"  class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-inline" style="width:40%">
                                        <label class="layui-form-label " >订单号</label>
                                        <div class="layui-input-block">
                                            <input type="text"  th:value="${model.orderNo}"  disabled="disabled"  class="layui-input">
                                        </div>
                                    </div>
                                </div>


                                <div class="layui-form-item" >
                                    <div class="layui-inline" style="width:40%">
                                        <label class="layui-form-label " >用户ID</label>
                                        <div class="layui-input-block">
                                            <input type="text"  th:value="${model.userId}" disabled="disabled"  class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-inline" style="width:40%">
                                        <label class="layui-form-label " >店铺ID</label>
                                        <div class="layui-input-block">
                                            <input type="text"  th:value="${model.shopId}"  disabled="disabled"  class="layui-input">
                                        </div>
                                    </div>
                                </div>


                                <div class="layui-form-item" >
                                    <div class="layui-inline" style="width:40%">
                                        <label class="layui-form-label "  >运费金额</label>
                                        <div class="layui-input-block" >
                                            <input type="text" name="freightAmount" th:value="${model.freightAmount}"  class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-inline" style="width:40%">
                                        <label class="layui-form-label "  >红包金额</label>
                                        <div class="layui-input-block" >
                                            <input type="text" name="redPackageAmount" th:value="${model.redPackageAmount}"  class="layui-input">
                                        </div>
                                    </div>
                                </div>


                                <div class="layui-form-item" >
                                    <div class="layui-inline" style="width:40%">
                                        <label class="layui-form-label "  >优惠券金额</label>
                                        <div class="layui-input-block" >
                                            <input type="text" name="couponAmount"  th:value="${model.couponAmount}"  class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-inline" style="width:40%">
                                        <label class="layui-form-label "  style="white-space: nowrap!important;">订单金额(不算折扣)</label>
                                        <div class="layui-input-block" style="margin-left: 160px;">
                                            <input type="text" name="totalAmount"  th:value="${model.totalAmount}"  class="layui-input">
                                        </div>
                                    </div>
                                </div>

                                <div class="layui-form-item" >
                                    <div class="layui-inline" style="width:40%">
                                        <label class="layui-form-label " style="white-space: nowrap!important;" >订单金额(折扣算完)</label>
                                        <div class="layui-input-block" style="margin-left: 160px;">
                                            <input type="text" name="orderAmount"  th:value="${model.orderAmount}"  class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-inline" style="width:40%">
                                        <label class="layui-form-label "  >付款金额</label>
                                        <div class="layui-input-block" >
                                            <input type="text" name="payAmount" th:value="${model.payAmount}"  class="layui-input">
                                        </div>
                                    </div>
                                </div>


                                <div class="layui-form-item" >
                                    <div class="layui-inline" style="width:80%">
                                        <label class="layui-form-label " style="white-space: nowrap!important;" >订单备注</label>
                                        <div class="layui-input-block"   style="margin-left: 120px;">
                                            <textarea name="remark" class="layui-textarea" th:text="${model.remark}" ></textarea>
                                        </div>
                                    </div>
                                </div>

                                <div class="layui-form-item" >
                                    <div class="layui-inline" style="width:40%">
                                        <label class="layui-form-label "  >交易流水号</label>
                                        <div class="layui-input-block" >
                                            <input type="text"  th:value="${model.outerTradeNo}"  class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-inline" style="width:40%">
                                        <label class="layui-form-label "  >支付状态</label>
                                        <div class="layui-input-block" th:if="${model.payStatus eq null}" >
                                            <select name="payStatus"  lay-search="">
                                                <option value="0" selected>未支付</option>
                                                <option value="1" >已支付</option>
                                                <option value="3" >线下支付已到账</option>
                                                <option value="4" >取消支付</option>
                                            </select>
                                        </div>
                                        <div class="layui-input-block" th:if="${model.payStatus eq 0}" >
                                            <select name="payStatus"  lay-search="">
                                                <option value="0" selected>未支付</option>
                                                <option value="1" >已支付</option>
                                                <option value="3" >线下支付已到账</option>
                                                <option value="4" >取消支付</option>
                                            </select>
                                        </div>
                                        <div class="layui-input-block" th:if="${model.payStatus eq 1}" >
                                            <select name="payStatus"  lay-search="">
                                                <option value="0" >未支付</option>
                                                <option value="1" selected>已支付</option>
                                                <option value="3" >线下支付已到账</option>
                                                <option value="4" >取消支付</option>
                                            </select>
                                        </div>
                                        <div class="layui-input-block" th:if="${model.payStatus eq 3}" >
                                            <select name="payStatus"  lay-search="">
                                                <option value="0" >未支付</option>
                                                <option value="1" >已支付</option>
                                                <option value="3" selected>线下支付已到账</option>
                                                <option value="4" >取消支付</option>
                                            </select>
                                        </div>
                                        <div class="layui-input-block" th:if="${model.payStatus eq 4}" >
                                            <select name="payStatus"  lay-search="">
                                                <option value="0" >未支付</option>
                                                <option value="1" >已支付</option>
                                                <option value="3" >线下支付已到账</option>
                                                <option value="4" selected>取消支付</option>
                                            </select>
                                        </div>
                                    </div>
                                </div>

                                <div class="layui-form-item" >

                                    <div class="layui-inline" style="width:40%">
                                        <label class="layui-form-label "  >交易状态</label>
                                        <div class="layui-input-block" th:if="${model.tradeStatus eq null}" >
                                            <select name="tradeStatus"  lay-search="">
                                                <option value="0" selected >待付款</option>
                                                <option value="1" >待收货</option>
                                                <option value="2" >已取消</option>
                                                <option value="3" >已完成</option>
                                            </select>
                                        </div>
                                        <div class="layui-input-block" th:if="${model.tradeStatus eq 0}" >
                                            <select name="tradeStatus"  lay-search="">
                                                <option value="0" selected>待付款</option>
                                                <option value="1" >待收货</option>
                                                <option value="2" >已取消</option>
                                                <option value="3" >已完成</option>
                                            </select>
                                        </div>
                                        <div class="layui-input-block" th:if="${model.tradeStatus eq 1}" >
                                            <select name="tradeStatus"  lay-search="">
                                                <option value="0" >待付款</option>
                                                <option value="1" selected>待收货</option>
                                                <option value="2" >已取消</option>
                                                <option value="3" >已完成</option>
                                            </select>
                                        </div>
                                        <div class="layui-input-block" th:if="${model.tradeStatus eq 2}" >
                                            <select name="tradeStatus"  lay-search="">
                                                <option value="0" >待付款</option>
                                                <option value="1" >待收货</option>
                                                <option value="2" selected>已取消</option>
                                                <option value="3" >已完成</option>
                                            </select>
                                        </div>
                                        <div class="layui-input-block" th:if="${model.tradeStatus eq 3}" >
                                            <select name="tradeStatus"  lay-search="">
                                                <option value="0" >待付款</option>
                                                <option value="1" >待收货</option>
                                                <option value="2" >已取消</option>
                                                <option value="3" selected>已完成</option>
                                            </select>
                                        </div>
                                    </div>

                                    <div class="layui-inline" style="width:40%">
                                        <label class="layui-form-label "  >支付方式</label>
                                        <div class="layui-input-block" th:if="${model.payMethod eq null}" >
                                            <select name="payMethod"  lay-search="">
                                                <option value="1" selected>线上支付</option>
                                                <option value="2" >线下支付</option>
                                            </select>
                                        </div>
                                        <div class="layui-input-block" th:if="${model.payMethod eq 1}" >
                                            <select name="payMethod"  lay-search="">
                                                <option value="1" selected>线上支付</option>
                                                <option value="2" >线下支付</option>
                                            </select>
                                        </div>
                                        <div class="layui-input-block" th:if="${model.payMethod eq 2}" >
                                            <select name="payMethod"  lay-search="">
                                                <option value="1" >线上支付</option>
                                                <option value="2" selected>线下支付</option>
                                            </select>
                                        </div>
                                    </div>
                                </div>


                                <div class="layui-form-item" >
                                    <div class="layui-inline" style="width:40%">

                                        <label class="layui-form-label "  >支付渠道</label>
                                        <div class="layui-input-block" th:if="${model.payType eq null}" >
                                            <select name="payType"  lay-search="">
                                                <option value="-1" >未确定</option>
                                                <option value="0" >微信</option>
                                                <option value="1" >支付宝</option>
                                            </select>
                                        </div>
                                        <div class="layui-input-block" th:if="${model.payType eq -1}" >
                                            <select name="payType"  lay-search="">
                                                <option value="-1" selected>未确定</option>
                                                <option value="0" >微信</option>
                                                <option value="1" >支付宝</option>
                                            </select>
                                        </div>
                                        <div class="layui-input-block" th:if="${model.payType eq 0}" >
                                            <select name="payType"  lay-search="">
                                                <option value="-1">未确定</option>
                                                <option value="0" selected>微信</option>
                                                <option value="1" >支付宝</option>
                                            </select>
                                        </div>
                                        <div class="layui-input-block" th:if="${model.payType eq 1}" >
                                            <select name="payType"  lay-search="">
                                                <option value="-1">未确定</option>
                                                <option value="0" >微信</option>
                                                <option value="1" selected>支付宝</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="layui-inline" style="width:40%">
                                        <label class="layui-form-label "  >支付时间</label>
                                        <div class="layui-input-block" >
                                            <input type="text" name="payDate" id="payDate" th:value="${#dates.format(model.payDate,'yyyy-MM-dd HH:mm:ss')}"  class="layui-input">
                                        </div>
                                    </div>
                                </div>


                                <div class="layui-form-item" >
                                    <div class="layui-inline" style="width:40%">
                                        <label class="layui-form-label " style="white-space: nowrap!important;" >取消订单时间</label>
                                        <div class="layui-input-block"   style="margin-left: 120px;">
                                            <input type="text"  th:value="${#dates.format(model.cancelDate,'yyyy-MM-dd HH:mm:ss')}"    class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-inline" style="width:40%">
                                        <label class="layui-form-label "  >创建时间</label>
                                        <div class="layui-input-block" >
                                            <input type="text"  th:value="${#dates.format(model.createDate,'yyyy-MM-dd HH:mm:ss')}"  disabled="disabled"  class="layui-input">
                                        </div>
                                    </div>
                                </div>

                                <div class="layui-inline" style="width:80%">
                                    <label class="layui-form-label " style="white-space: nowrap!important;" >取消订单备注</label>
                                    <div class="layui-input-block"   style="margin-left: 120px;">
                                        <textarea name="cancelRemark"  class="layui-textarea" th:text="${model.cancelRemark}" ></textarea>
                                    </div>
                                </div>


                        </div>

                        <div class="layui-inline" style="width:80%">
                            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                                <legend>收货人信息</legend>
                            </fieldset>
                            <div class="layui-form-item" >
                                <div class="layui-inline" style="width:40%">
                                    <label class="layui-form-label " >收货人</label>
                                    <div class="layui-input-block">
                                        <input type="text" id="orderConsigneeAddress_name"  th:value="${model.orderConsigneeAddress.name}"  class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-inline" style="width:40%">
                                    <label class="layui-form-label " >收货人电话</label>
                                    <div class="layui-input-block">
                                        <input type="text" id="orderConsigneeAddress_phone"  th:value="${model.orderConsigneeAddress.phone}"  class="layui-input">
                                    </div>
                                </div>
                            </div>


                            <div class="layui-form-item" >
                                <div class="layui-inline" style="width:40%">
                                    <label class="layui-form-label " >省份编码</label>
                                    <div class="layui-input-block">
                                        <input type="text"  id="orderConsigneeAddress_provinceCode" th:value="${model.orderConsigneeAddress.provinceCode}" readonly  class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-inline" style="width:40%">
                                    <label class="layui-form-label " >省份名称</label>
                                    <div class="layui-input-block">
                                        <select id="orderConsigneeAddress_provinceName" lay-filter="orderConsigneeAddress_provinceName"></select>
                                    </div>
                                </div>
                            </div>



                            <div class="layui-form-item" >

                                <div class="layui-inline" style="width:40%">
                                    <label class="layui-form-label " >地市编码</label>
                                    <div class="layui-input-block">
                                        <input type="text" id="orderConsigneeAddress_cityCode"  th:value="${model.orderConsigneeAddress.cityCode}" readonly  class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-inline" style="width:40%">
                                    <label class="layui-form-label " >地市名称</label>
                                    <div class="layui-input-block">
                                        <select id="orderConsigneeAddress_cityName" lay-filter="orderConsigneeAddress_cityName"></select>
                                    </div>
                                </div>
                            </div>



                            <div class="layui-form-item" >
                                <div class="layui-inline" style="width:40%">
                                    <label class="layui-form-label " >区县编码</label>
                                    <div class="layui-input-block">
                                        <input type="text"  id="orderConsigneeAddress_areaCode" th:value="${model.orderConsigneeAddress.areaCode}" readonly  class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-inline" style="width:40%">
                                    <label class="layui-form-label " >区县名称</label>
                                    <div class="layui-input-block">
                                        <select id="orderConsigneeAddress_areaName" lay-filter="orderConsigneeAddress_areaName"></select>
                                    </div>
                                </div>
                            </div>

                            <div class="layui-inline" style="width:80%">
                                <label class="layui-form-label "  >收货地址</label>
                                <div class="layui-input-block"  >
                                    <textarea id="orderConsigneeAddress_address" class="layui-textarea" th:text="${model.orderConsigneeAddress.address}" ></textarea>
                                </div>
                            </div>

                            <div class="layui-form-item" style="text-align:center;margin-top: 20px;" >
                                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="orderUpdateBtn">确认保存</button>
                            </div>
                        </div>

                        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                            <legend>订单项列表</legend>
                        </fieldset>
                        <table class="layui-hide" id="orderItemSkuTable" ></table>

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script th:src="@{/lib/layui-v2.5.5/layui.js}" charset="utf-8"></script>
<script>


    layui.use(['form','element', 'table','carousel','laydate'], function () {
        var $ = layui.jquery,
            table = layui.table,
            element = layui.element; //Tab的切换功能，切换事件监听等，需要依赖element模块

        var orderId = $("#id").val();
        var laydate = layui.laydate;
        var loadding;
        var form = layui.form;
        var provinceCityAreaLoadCount=0;
        var orderConsigneeAddress_provinceCode=$("#orderConsigneeAddress_provinceCode").val();
        var orderConsigneeAddress_cityCode=$("#orderConsigneeAddress_cityCode").val();
        var orderConsigneeAddress_areaCode=$("#orderConsigneeAddress_areaCode").val();
        var provinceCache=new Array();
        var cityCache=new Array();


        //初始化时间控件
        laydate.render({
            elem: '#payDate' //指定元素
            ,type: 'datetime'
        });


        function loadConsigneeAddressProvince(){
            var loadding = layer.load();
            $.ajax({
                url:"[[@{/area/list/by/parentCode/-1}]]",
                contentType: "application/json; charset=utf-8",
                type:'GET',
                success:function(data){
                    var optionHtml="";
                    provinceCache.splice(0,provinceCache.length);
                    for(var i=0;i<data.data.length;i++) {
                        var provinceObj = data.data[i];
                        var provinceName="";
                        if(provinceObj.isMunicipality==1)
                        {
                            provinceName = provinceObj.city;
                        }else{
                            provinceName = provinceObj.province;
                        }
                        if(orderConsigneeAddress_provinceCode==provinceObj.code)
                        {
                            optionHtml += "<option value='" + provinceObj.code + "' selected='selected'>" + provinceName + "</option>";
                            $("#orderConsigneeAddress_provinceCode").val(provinceObj.code);
                        }else {
                            optionHtml += "<option value='" + provinceObj.code + "'>" + provinceName + "</option>";
                        }
                        provinceCache.push({provinceName:provinceName,isMunicipality:provinceObj.isMunicipality,code:provinceObj.code});
                    }
                    $("#orderConsigneeAddress_provinceName").empty();
                    $("#orderConsigneeAddress_provinceName").append(optionHtml);
                    form.render();

                    provinceCityAreaLoadCount++;
                    layer.close(loadding);
                    loadConsigneeAddressCity(orderConsigneeAddress_provinceCode);
                }
            });
        }

        form.on('select(orderConsigneeAddress_provinceName)', function (data) {
            $("#orderConsigneeAddress_provinceCode").val(data.value);
            orderConsigneeAddress_provinceCode = data.value;
            //如果是直辖市,选择用当前编码加载区县
            var isMunicipality=false;
            for(var i=0;i<provinceCache.length;i++)
            {
                if(data.value==provinceCache[i].code)
                {
                    if(provinceCache[i].isMunicipality==1)
                    {
                        isMunicipality=true;
                        loadConsigneeAddressArea(data.value);
                        break;
                    }
                }
            }
            loadConsigneeAddressCity(data.value);
            //用第一个编码加载区县
            if(!isMunicipality)
            {
                $("#orderConsigneeAddress_cityCode").val(cityCache[0].code);
                loadConsigneeAddressArea(cityCache[0].code);
            }
        });



        function loadConsigneeAddressCity(parentCode){
            var isMunicipality=false;
            $("#orderConsigneeAddress_cityName").empty();
            for(var i=0;i<provinceCache.length;i++)
            {
                if(parentCode==provinceCache[i].code&&provinceCache[i].isMunicipality==1)
                {
                    isMunicipality=true;
                    $("#orderConsigneeAddress_cityName").append("<option value='" + provinceCache[i].code + "' selected='selected'>" + provinceCache[i].provinceName + "</option>");
                    $("#orderConsigneeAddress_cityCode").val(provinceCache[i].code);
                    orderConsigneeAddress_cityCode = provinceCache[i].code;
                    loadConsigneeAddressArea(orderConsigneeAddress_cityCode);
                    form.render();
                    break;
                }
            }
            if(!isMunicipality) { //如果不是直辖市,加载下面的地市
                var loadding = layer.load();
                $.ajax({
                    url: "[[@{/area/list/by/parentCode/}]]" + parentCode,
                    contentType: "application/json; charset=utf-8",
                    type: 'GET',
                    success: function (data) {
                        var optionHtml = "";
                        var isDefaultSelect = false;
                        cityCache.splice(0, provinceCache.length);
                        for (var i = 0; i < data.data.length; i++) {
                            var cityObj = data.data[i];
                            var cityName = cityObj.city;
                            if (orderConsigneeAddress_cityCode == cityObj.code) {
                                optionHtml += "<option value='" + cityObj.code + "' selected='selected'>" + cityName + "</option>";
                                $("#orderConsigneeAddress_cityCode").val(cityObj.code);
                                isDefaultSelect = true;
                            } else {
                                optionHtml += "<option value='" + cityObj.code + "'>" + cityName + "</option>";
                            }
                            cityCache.push({cityName: cityName, code: cityObj.code});
                        }
                        $("#orderConsigneeAddress_cityName").append(optionHtml);
                        //默认选中第一个
                        if (!isDefaultSelect) {
                            orderConsigneeAddress_cityCode = data.data[0].code;
                            $("#orderConsigneeAddress_cityCode").val(data.data[0].code);
                            $('#orderConsigneeAddress_cityName:selected').val(data.data[0].code);
                        }
                        form.render();
                        provinceCityAreaLoadCount++;
                        layer.close(loadding);

                        loadConsigneeAddressArea(orderConsigneeAddress_cityCode);
                    }
                });
            }
        }
        form.on('select(orderConsigneeAddress_cityName)', function (data) {
            $("#orderConsigneeAddress_cityCode").val(data.value);
            loadConsigneeAddressArea(data.value);
        });

        function loadConsigneeAddressArea(parentCode){
            var loadding = layer.load();
            $.ajax({
                url:"[[@{/area/list/by/parentCode/}]]"+parentCode,
                contentType: "application/json; charset=utf-8",
                type:'GET',
                success:function(data){
                    var optionHtml="";
                    var isDefaultSelect=false;
                    for(var i=0;i<data.data.length;i++) {
                        var areaObj = data.data[i];
                        var areaName=areaObj.area;
                        if(orderConsigneeAddress_areaCode==areaObj.code)
                        {
                            optionHtml += "<option value='" + areaObj.code + "' selected='selected'>" + areaName + "</option>";
                            isDefaultSelect=true;
                        }else {
                            optionHtml += "<option value='" + areaObj.code + "'>" + areaName + "</option>";
                        }
                    }
                    $("#orderConsigneeAddress_areaName").empty();
                    $("#orderConsigneeAddress_areaName").append(optionHtml);
                    //默认选中第一个
                    if(!isDefaultSelect)
                    {
                        $('#orderConsigneeAddress_areaName:selected').val(data.data[0].code);
                        $("#orderConsigneeAddress_areaCode").val(data.data[0].code);
                    }
                    form.render();
                    provinceCityAreaLoadCount++;
                    layer.close(loadding);
                }
            });
        }
        form.on('select(orderConsigneeAddress_areaName)', function (data) {
            $("#orderConsigneeAddress_areaCode").val(data.value);
        });

        loadConsigneeAddressProvince();

        //监听提交
        form.on('submit(orderUpdateBtn)', function (data) {
            if(provinceCityAreaLoadCount<3)
            {
                layer.msg("收货人信息没有加载结束，请稍候");
                return;
            }
            loadding = layer.load();
            var paramObj = data.field;
            //收货人
            paramObj.orderConsigneeAddress={
                name:$("#orderConsigneeAddress_name").val(),
                phone:$("#orderConsigneeAddress_phone").val(),
                provinceCode:$("#orderConsigneeAddress_provinceCode").val(),
                provinceName:$("#orderConsigneeAddress_provinceName").find("option:selected").text(),
                cityCode:$("#orderConsigneeAddress_cityCode").val(),
                cityName:$("#orderConsigneeAddress_cityName").find("option:selected").text(),
                areaCode:$("#orderConsigneeAddress_areaCode").val(),
                areaName:$("#orderConsigneeAddress_areaName").find("option:selected").text(),
                address:$("#orderConsigneeAddress_address").val()
            };

            $.ajax({
                url:"[[@{/order/update}]]",
                contentType: "application/json; charset=utf-8",
                type:'POST',
                data:JSON.stringify(paramObj),
                success:function(data){
                    if(data.code<=0) {
                        layer.msg(data.msg);
                        return false;
                    }
                    var index = layer.alert(data.msg, {
                        title: '提示信息'
                    }, function () {
                        // 关闭弹出层
                        layer.close(index);
                        var iframeIndex = parent.layer.getFrameIndex(window.name);
                        parent.location.reload();
                        parent.layer.close(iframeIndex);

                    });
                },
                complete:function()
                {
                    layer.close(loadding);
                }
            });
            return false;
        });

        table.render({
            elem: '#orderItemSkuTable',
            url: "[[@{/}]]order/orderItem/list",
            method:'POST',
            where:{orderId:orderId},
            done:function(res, curr, count)
            {
            },
            cols: [
                [
                    {field: 'skuId',  title: '商品SKUID', width: 180},
                    {field: 'productSkuName',  title: '商品名称', width: 320},
                    {field: 'httpProductPreviewPath', width: 150, title: '商品预览',
                        templet: function (row) {
                            if(row.httpProductPreviewPath!=null) {
                                return "<a href='" + row.httpProductPreviewPath + "' target='_blank'><img src='" + row.httpProductPreviewPath + "' width='100' height='100'  /></a>";
                            }
                            return "";
                        }},
                    {field: 'deliveryStatus',  title: '配送状态', width: 100,
                        templet: function (row) {
                            if(row.deliveryStatus==0) {
                                return "未收货";
                            }
                            if(row.deliveryStatus==1) {
                                return "送货中";
                            }
                            if(row.deliveryStatus==2) {
                                return "已收货";
                            }
                            return row.deliveryStatus;
                        }},
                    {field: 'sellerStatus',  title: '卖家备货状态', width: 150,
                        templet: function (row) {
                            if(row.sellerStatus==0) {
                                return "备货中";
                            }
                            if(row.sellerStatus==1) {
                                return "备货完成";
                            }
                            if(row.sellerStatus==2) {
                                return "缺货";
                            }
                            return row.sellerStatus;
                        }},
                    {field: 'buyerStatus',  title: '买家状态', width: 100,
                        templet: function (row) {
                            if(row.buyerStatus==0) {
                                return "待收货";
                            }
                            if(row.buyerStatus==1) {
                                return "已收货";
                            }
                            if(row.buyerStatus==2) {
                                return "换货";
                            }
                            if(row.buyerStatus==3) {
                                return "退货";
                            }
                            return row.buyerStatus;
                        }},
                    {field: 'productPrice',  title: '商品单价', width: 120},
                    {field: 'productNum',  title: '购买数量', width: 120},
                    {field: 'orderItemAmount',  title: '总金额', width: 120},
                    {field: 'deliveryReceiveTime',  title: '收货时间', width: 120},
                    {field: 'deliveryFinishTime',  title: '配送完成时间', width: 120},
                    {field: 'sellerFinishTime',  title: '卖家完成时间', width: 120},
                    {field: 'buyerFinishTime',  title: '买家完成时间', width: 120},
                    {field: 'freightTemplateId',  title: '运费模板ID', width: 120}



                ]
            ],
            limits: [15,30,100,200],
            limit: 15,
            page: true,
            skin: 'line'
        });


    });
</script>
</body>
</html>